<?php
if(!session_is_registered($_SESSION['uid'])){
               
            header("location:tools.php");
    }
    else
        header( "location:index.php");
?>

<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tools Page</title>
        <link rel="stylesheet" type="text/css" href="http://localhost/ReefersLogApp/CSS/Generalpagelayout.css" />
    </head>
    <div id="container">
	<div id="header">
            <h1>
		Reefers Log Tools
            </h1>
	</div>
	<div id="navigation">
		<ul>
			<li><a href="./../WelcomePage/WelcomePage.php">Home</a></li>
			<li><a href="./../Profile/userprofile.php">Profile</a></li>
			<li><a href="./../Tools/tools.php">Tools</a></li>
			<li><a href="./../Logout/logout.php">Logout</a></li>
		</ul>
	</div>
	<div id="content-container">
		<div id="section-navigation">
			<ul>
				<li><a href="./../Maintenance/maintenancelog.php">View Maintenance Log</a></li>
				<li><a href="./../Maintenance/waterchange.html">Water Change</a></li>
				<li><a href="./../Test_logs/watertest.html">Water Test</a></li>
			</ul>
		</div>
		<div id="content">
                    <h2>
                        Your Aquarium Statistics:
                    </h2>
                    <p>
                        Use the links below for tools that aid in helpful aquarium conversions and information. 
                    </p>
                    
                   
                    <form name="alk" action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "GET">
                    <table border="1">
                        <thead>
                            <tr>
                                <th>Akalinity Converter</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                 <td>Alkalinity: <input type = "text" name = "alk" size=3 value=""> 
                                 <select name="scale"> 
                                     <option value="dkh">DKH</option> 
                                     <option value="meq">Meq/L</option> 
                                 </select> <br/> 
                                 <input type = "submit" name = "convertalk"/> </td>                                
                        </tbody>
                    </table>
                    </form>
                    </br>

                    
                    <!--PHP conversion function for alk-->              
                    <?php 
                    
                    $scale = $_GET['scale'];
                    $alk = $_GET['alk'];
                    
                    if ($scale == "dkh") {print "<table border></br><tr><th colspan=2> Conversion Results</th></tr><tr><td>$alk</td><td>DKH</td></tr>"; 
                    $d_2_m = $alk/2.8; print "<tr><td>$d_2_m</td><td>MEQ/L</td></tr>";}
                    
                    if ($scale == "meq") {print "<table border></br><tr><th colspan=2> Conversion Results</th></tr><tr><td>$alk</td><td>DKH</td></tr>"; 
                    $m_2_d = $alk*2.8; print "<tr><td>$m_2_d</td><td>DKH</td></tr>";}
                    ?>
                    
                    <form name="temp" action="<?php echo $_SERVER['PHP_SELF'];?>" method = "GET">
                    <table border="1">
                        <thead>
                            <tr>
                                <th>Temperature Conversion:</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                 <td>Degrees:<input type = "text" name = "degree" size=4 value=""> 
                                 <select name="scale"> 
                                     <option value="celcius">Celsius</option> 
                                     <option value="fahrenheit">Fahrenheit</option> 
                                 </select> <br/> 
                                 <input type = "submit" name = "Convert Temperature"/> </td>              
                            </tr>
                        </tbody>
                    </table>                  
                    </form>
                    </br>
                    
                    <!--PHP conversion function for temperature--> 
                    <?php
                    
                     $scale = $_GET['scale'];
                     $degree = $_GET['degree'];
 
                    if ($scale == "celcius") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td>$degree</td><td>celsius</td></tr>"; 
                    $c_2_f = $degree*9/5+32; print "<tr><td>$c_2_f</td><td>fahrenheit</td></tr>";}
                    
                    
                    if ($scale == "fahrenheit") {print "<table border><tr><th colspan=2> Conversion Results</th></tr><tr><td>$degree</td><td>farhenheit</td></tr>"; 
                    $f_2_c = ($degree -32)*5/9; print "<tr><td>$f_2_c</td><td>celsius</td></tr>";}
                    ?>
  
                    
		</div>
		<div id="aside">
                    <h3>
                        Tools Section
                    </h3>
		</div>
		<div id="footer">
			Copyright © ReefersLog, 2012, wkoester All Rights Reserved 
		</div>
	</div>
    </div>
</html>
